import { request } from "./request"

//获取分类参数
export async function getHttpParamsData(id, type) {
  return await request({
    method: "get",
    url: "categories/" + id + "/attributes",
    params: {
      sel: type
    }
  })
}

//添加分类
export async function postHttpAddParams(addForm) {
  return await request({
    method: "post",
    url: "categories/"+ addForm.id +"/attributes",
    data: addForm
  })
}

//修改分类信息
export async function putHttpEditParams(editForm) {
  return await request({
    method: "put",
    url: 'categories/'+ editForm.id +'/attributes/' + editForm.attrId,
    data: editForm
  })
}

//删除单个参数
export async function deleteHttpDeleteParamsById(id, attrid) {
  return await request({
    method: "delete",
    url: 'categories/'+ id +'/attributes/' + attrid
  })
}

//添加参数属性
export async function putHttpAddAttrVals(id, attrId, attr_name, attr_sel, attr_vals) {
  return await request({
    method: "put",
    url: 'categories/'+ id +'/attributes/' + attrId,
    data: {
      attr_name,
      attr_sel,
      attr_vals
    }
  })
}
